﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DataService
{
    /// <summary>
    /// Summary description for CacheFactory
    /// </summary>
    public static class CacheFactory
    {
        public static readonly string UserListKey;
        public static readonly string MessageKey;
        public static readonly string RemoveMessageKey;
        private static Dictionary<string, object> cacheCollection;
        static CacheFactory()
        {
            cacheCollection = new Dictionary<string, object>();
            UserListKey = "UserListKey";
            MessageKey = "MessageKey";
            RemoveMessageKey = "RemoveMessageKey";
        }

        public static ICacheService<T> GetCacheService<T>(string key)
        {
            if (cacheCollection.ContainsKey(key))
                return cacheCollection[key] as ICacheService<T>;

            ICacheService<T> cache = new FCLCacheService<T>();
            cacheCollection.Add(key, cache);
            return cache;
        }
    }
}